package com.qianbao.controller.v1.money;

import com.qianbao.components.excepion.CommonException;
import com.qianbao.components.svresut.Result;
import com.qianbao.components.svversion.ApiVersion;
import com.qianbao.domain.widthdraw.WidthdrawEntity;
import com.qianbao.service.money.WidthdrawService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.validation.Valid;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;

@Controller
@ApiVersion(1)
@RequestMapping("/moneycenter/widthdraw/{version}/")
public class WidthdrawController {


    @Autowired
    private WidthdrawService widthdrawService;

    @RequestMapping("/save-widthdraw-information")
    @ResponseBody
    public Result saveUserCoinWithType(@Valid WidthdrawEntity entity){

        try {
            widthdrawService.saveUserWidthdrawInformation(entity);
            return Result.success(Collections.emptyMap());
        } catch (CommonException e) {
            e.printStackTrace();
            return Result.fail(e.getCode(),e.getMessage());
        }
    }


    @RequestMapping("/find-widthdraw-record")
    @ResponseBody
    public Result findWidthdrawRecord(String custom_id){
        try {
            List<WidthdrawEntity> entityList = widthdrawService.findUserWidthdrawRecord(custom_id);
            HashMap<String,List> map = new HashMap<>();
            map.put("list",entityList);
            return Result.success(map);
        } catch (CommonException e) {
            e.printStackTrace();
            return Result.fail(e.getCode(),e.getMessage());
        }
    }




}

























